package com.ruibang.glass.equipment.controller;


import com.ruibang.glass.equipment.constant.Constants;
import com.ruibang.glass.equipment.domain.req.device.BoilerInfoPageReq;
import com.ruibang.glass.equipment.entity.device.BoilerInfo;
import com.ruibang.glass.equipment.service.BoilerInfoService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 锅炉接口服务
 * </p>
 *
 * @author mameng
 * @since 2024-03-20
 */

@RestController
@RequestMapping("api/equipment/boiler/info")
public class BoilerInfoController {
    @Autowired
    private BoilerInfoService boilerInfoService;

    @PostMapping("list")
    @ApiOperation(value = "获取锅炉列表", response = ResultBody.class)
    public ResultBody getBoilerList(@RequestBody BoilerInfoPageReq boilerInfo) {
        return ResultBody.success(boilerInfoService.queryBoilerList(boilerInfo));
    }

    @PostMapping("/deleteById")
    @ApiOperation(value = "删除实体", response = ResultBody.class)
    public ResultBody deleteById(@RequestBody BoilerInfo boilerInfo) {
        boilerInfoService.lambdaUpdate().set(BoilerInfo::getIsDelete, Constants.ONE_STR).eq(BoilerInfo::getId, boilerInfo.getId()).update();
        return ResultBody.success();
    }

    @PostMapping("/getBoilerInfo")
    @ApiOperation(value = "根据产线获取区域", response = ResultBody.class)
    public ResultBody getBoilerInfoById(@RequestBody BoilerInfo boilerInfo) {
        BoilerInfo byId = boilerInfoService.getById(boilerInfo.getId());
        return ResultBody.success(byId);
    }

    @PostMapping("/updateBoilerInfo")
    @ApiOperation(value = "根据产线获取区域", response = ResultBody.class)
    public ResultBody updateBoilerInfo(@RequestBody BoilerInfo boilerInfo) {
        return ResultBody.success(boilerInfoService.updateOrAddById(boilerInfo));
    }
}
